package com.nb.sse.controller;

import com.nb.sse.constant.ChannelConstant;
import com.nb.sse.subscribe.RedisMessageSubscriber;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.listener.ChannelTopic;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

/**
 * @author lihaoyang6
 * @date 2024年07月14日 21:18
 */
@RestController
public class RedisPubSubController {

    @Autowired
    RedisTemplate<String, Object> redisTemplate;

    @Autowired
    RedisMessageSubscriber redisMessageSubscriber;




    /**
     * 发布广播消息
     *
     * @param msg
     */
    @GetMapping(value = "/publish")
    public void sendMsg(String msg) {
        redisTemplate.convertAndSend(ChannelConstant.CHANNEL_GLOBAL, msg);
    }



}
